class Solution {
public:
    ListNode* mergeTwoLists(ListNode* list1, ListNode* list2) {
        ListNode* h1=list1,*h2=list2;
        if(h1==nullptr) return h2;
        if(h2==nullptr) return h1;
        if(h1->val>h2->val){
          h2->next=mergeTwoLists(h1,h2->next);
          return h2;
        }else{
          h1->next=mergeTwoLists(h1->next,h2);
          return h1;
        }
    }
};
